Code:
530622021,20,02,4d,6,52000a58,00,111278fffffffffffff8
530625446,20,02,86,6,52000a55,00,ffffff8e1937ffffffc8
530256885,20,01,e5,3,52000a4a,00,3cffffffffffffffffff
530256887,20,01,7a,3,52000a4b,00,1713161620ffffffffff
530256886,20,01,dc,3,52000a4c,00,881b8ad8758c8dffffff
530256816,20,01,a2,3,52000a4d,00,ffffffffffffffffffff
530256884,20,01,52,3,52000a4e,00,18164af55e72a6ffffff
530256885,20,01,e5,3,52000a4a,00,3cffffffffffffffffff
530256887,20,01,7a,3,52000a4b,00,1713161620ffffffffff
530256886,20,01,dc,3,52000a4c,00,881b8ad8758c8dffffff
using this new code I made
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
// Declare Variables
char direct[2048]; // Used to store the char string array of the current programs directory (so the program will work even if you move it around)
getcwd(direct); // Gets the "current working directory" (cwd) of the program
strcat(direct, "\\code.txt"); // Adds the name of the textfile on the end of the directory path
char lineOfText[1000][200] = {0}; // Holds each line and character of the textfile
FILE *myFileHand; // Used to handle the file
int i = 0, k = 0, j = 0, ii = 0, iii = 0; // Counters
int lines; // Used to count the number of lines in the textfile
char time[1000][8]; //The time in seconds when it was sent
char type[1000][2]; //Type code to idtentify the device (0x20)
char version[1000][2] = {0}; //software version
char counter[1000][2]; //A rolling 8-bit, ever increasing number. Used to show how many messages are being missed by the receiver
char via[1000][1]; //Which receiver picked up this device’s transmission
char address[1000][8]; //The address of the transmitter
char status[1000][2]; //The status code of the device
char sensorData[1000][128]; //10-bytes of sensor data in hex (each sensor being 1 byte and 10 sensors)
/*+==================================================+
File Handling
+==================================================+*/
myFileHand = fopen("1000.csv", "r");
if(myFileHand != NULL) { // reading the text file into a 2D array as well as counting the number of lines it has
char line[150];
while (fgets(line, 150, myFileHand) != NULL) {
strcpy(lineOfText[j], line);
printf("LINE: %s\n", lineOfText[j]);
printf("LINENO: %d\n", j);
j++;
lines++;
}
fclose(myFileHand);
}
}
I am able to read in the file.